
//
// type MembersListView -- view for MembersList
//
function MembersListView(dom_elt) {
		this._de = dom_elt;
		this.getMembersList  = function() { return jQuery(this._de).find("tr.row-"); }
}
MembersListView.prototype._bind      = function(model) { 
		this.model = model; 
		this.bind();
		return this;
}
MembersListView.prototype.bind       = function() { 
}

//
// type MemberView -- view for member
//

function MemberView(dom_elt) {
		//window.console.log(dom_elt);
		this._de = dom_elt;
		this.model = null;
}
MemberView.prototype._bind           = function(model) { 
		this.model = model; 
		this.bind();
		return this;
}
MemberView.prototype.bind            = function() { 
		jQuery(this._de).bind("mouseover", this.onMouseOver);
		jQuery(this._de).bind("mouseout", this.onMouseOut);
		jQuery(this.getRoleSelector()).bind("change", this.model, this.model.onChangeRole);
		jQuery(this.getDeleteButton()).bind("click", this.model, this.model.onDelete);
}
MemberView.prototype.onMouseOver     = function(event) { return jQuery(this).addClass('row-selected-'); }
MemberView.prototype.onMouseOut      = function(event) { if (!jQuery(event.target).hasClass('selector-')) return jQuery(this).removeClass('row-selected-'); }

MemberView.prototype.getRoleSelector = function() { return jQuery(this._de).find(".selector-").get(0); }
MemberView.prototype.getDeleteButton = function() { return jQuery(this._de).find('.delete-').get(0); }
MemberView.prototype.getUserId       = function() { return jQuery(this._de).find('.userid-').val(); }
MemberView.prototype.getAjaxUrl      = function() { return jQuery('#member_submit_url').attr('href'); }
MemberView.prototype.rmPanel         = function() { jQuery(this._de).remove(); }

MemberView.prototype.notifyChange    = function() { 
    jQuery(this._de).removeClass('changed-').removeClass('error-').addClass('change-'); 
    jQuery(this._de).find('.current-').get(0).innerHTML = jQuery(this._de).find('.selector- option:selected').text();
}
MemberView.prototype.notifyChanged   = function() { jQuery(this._de).removeClass('change-').removeClass('error-').addClass('changed-'); }
MemberView.prototype.notifyError     = function() { jQuery(this._de).removeClass('changed-').removeClass('change-').addClass('error-'); }



/// do it
jQuery().ready(function () {
    var mp = new MembersList(jQuery("#userstable").get(0));
    mp.bind();
});
